# Note:
# The examples can not be run without having the map data installed before!
try( {
# define the ids for the cantons and the according colors
PlotKant(id=c("GR","ZH","VS"), col=c("lightgrey","lightblue","lightsalmon"))
require(DescTools)
# get some percentage values...
some_p <- c(AG=0.48,AI=0.47,AR=0.4,BE=0.48,BL=0.44,BS=0.4,FR=0.48,GE=0.28,GL=0.51,
GR=0.4,JU=0.61,LU=0.49,NE=0.54,NW=0.43,OW=0.58,SG=0.45,SH=0.36,SO=0.45,
SZ=0.39,TG=0.47,TI=0.46,UR=0.4,VD=0.46,VS=0.45,ZG=0.41,ZH=0.41)
# and a color ramp from white to hred
cols <- colorRampPalette(c("white", hred))(100)
PlotKant(id=names(some_p), col=FindColor(some_p, cols=cols), main="ECO in CH")
ColorLegend(x="left", inset=-0.01, cols=cols,
labels=formatC((seq(0, 1, .2)), digits=2, format="f"),
width=12000, frame="grey", cex=0.8 )
# greater regions
PlotGreg(col=colorRampPalette(c("blue", "white", "red"), space = "rgb")(7),
main="Greater Regions CH")
PlotGreg(id = c(2,4,7), col = c("bisque","darkolivegreen1","khaki"),
main="Espace Mittelland, Zurich und Ticino")
AddLakes(col="grey90", border="darkgrey")
xy <- sf::st_coordinates((greg.pnt <- GetMap("greg.pnt"))$geometry[c(2,4,7)])
text(xy[,1], xy[,2], greg.pnt$name[c(2,4,7)], col="black")
# plot the districts
bezk.map <- GetMap("bezk.map")
head(bezk.map)
PlotBezk(id=311:316, col=colorRampPalette(c("red", "white", "blue"), space = "rgb")(5))
PlotBezk(id=bezk.map[[1]], col=rainbow(147), main="Districts in CH")
cols <- c(y=rgb(255,247,174,max=255), o=rgb(251,208,124,max=255),
v=rgb(228,201,224,max=255), b=rgb(211,230,246,max=255),
g=rgb(215,233,205,max=255), r=rgb(244,182,156,max=255),
p=rgb(255,248,236,max=255))
# display MS regions
# start with a cantons map
# start with a cantons map
PlotKant(1:26,col=cols[c("g","g","o","r","v","b","y","g","y","o",
"v","o","y","v","y","v","o","y","r","b",
"v","y","b","r","v","b")],
border="grey20", lwd=1, pbg=cols["p"],
main="106 MS-Regions")
# add the MS regions borders
xy <- PlotMSRe(add=TRUE, border="grey60")
# reoutline the cantons, as they have been overplotted in the step before
PlotKant(1:26, add=TRUE, border="grey30", lwd=1)
# add the waters
AddLakes(1:2, col=rgb(235, 247, 253, max=255), border=rgb(0,166,235, max=255))
AddRivers(1:5, col=rgb(0, 166, 235, max=255))
# ... and finally add labels
text(x=xy$x, y=xy$y, GetMap("msre.map")$id, cex=0.6)
# plot political communities
# plot only the first 10 elements
PlotPolg(id=1:10,
col=colorRampPalette(c("red", "white", "blue"), space = "rgb")(10))
# plot all communities
PlotPolg(id=(map <- GetMap("polg.map"))$id, col=rainbow(nrow(map)),
main="Political communities in CH")
})
Run the code above in your browser using DataLab